package com.cskaoyan.controller;

import com.cskaoyan.bean.BaseRespVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * @author stone
 * @date 2022/07/11 09:34
 */
@Controller //注册为容器中的Controller组件
public class HelloController {

    /*@Autowired
    UserService userService;*/

    // hello方法可以称之为Handler方法
    @RequestMapping("hello")
    @ResponseBody
    // method.invoke(instance,args)
    public BaseRespVo hello(String username) {
        BaseRespVo baseRespVo = new BaseRespVo();
        baseRespVo.setMsg("成功");
        baseRespVo.setData("hello springmvc");
        baseRespVo.setStatus(200);
        return baseRespVo;
    }

    public HelloController() {
        System.out.println("hello controller init");
    }
}
